home *** CD-ROM | disk | FTP | other *** search
- Path: news2.near.net!ceylon!news
- From: Brenda <g051286>
- Newsgroups: comp.lang.c
- Subject: Re: What is &Variable (declared as: char Variable[10])?
- Date: 26 Feb 1996 21:56:54 GMT
- Organization: GTE Laboratories Incorporated
- Message-ID: <4gtab6$acb@ceylon.gte.com>
- References: <4gqpa1$3h9@alcor.usc.edu> <4gsdno$1bg@umbc9.umbc.edu>
- NNTP-Posting-Host: 138.83.161.16
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.1N (X11; I; HP-UX A.09.05 9000/735)
- X-URL: news://132.197.8.2/4gsdno$1bg@umbc9.umbc.edu
-
- schlein@umbc.edu (Jonas J. Schlein) wrote:
- >Abu Wawda <wawda@alcor.usc.edu> wrote:
- >|> I'm having trouble understanding what the address of a static array
- >|> is.
- >
- >I'm having trouble understanding why it matters? You almost never use the
- >address of an array directly unless doing something tricky with pointers
- >or with particular dimensions of a multiple dimensional array.
- >
- >|> For example, if I declare a variable called myarray as:
- >|> char myarray[10];
- >|> then what could &myarray possibly mean? myarray is not a pointer, so
- >|> &myarray could not possibly be the address of the variable myarray
- >|> (like it would be if I did char* myarray and then asked for &myarray).
- >
- >Yes it could and yes it is...'myarray' is not a pointer, but &myarray is
- >a pointer to 'myarray'.
-
- Um, that's not correct. myarray is DEFINITELY a pointer! As declared above,
- it is a constant pointer to 10 contiguous char datatypes. myarray is an
- ADDRESS whereas *(myarray + 5) or myarray[5] is the 6th element in the array.
- The difference between an array and something like "char *p=myarray", is that
- you can say p++, but you can't say myarray++. You shouldn't say &myarray
- either because myarray is a constant, but I read that on some compilers
- scanf ignores the dereferencing and does not bother to warn you.
-
- Hope this helps.
-
- Brenda
-
-